<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>


<%@ include file="head.jsp"%>

<style>
	.text-danger {
		margin-top: 5px;
	}
	
	/* #ueditor_container{
		height: 500px;
	} */
	
	 #id_form {
		padding-bottom: 50px;
	} 
</style>

    <!-- 配置文件 -->
    <script type="text/javascript" src="${baseurl }/resources/public/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="${baseurl }/resources/public/ueditor/ueditor.all.js"></script>
    
<script>
	$(function(){
		
		 var ue = UE.getEditor('container' , {
			 initialFrameHeight : 500
		 });
		
		// 头像文件格式验证和预览
		$("#images").change(function() {
			var v = $(this).val();

			var extArr = v.split(".");
			var ext = extArr[extArr.length - 1];// 取最后一个字符串（就是扩展名）
			// 扩展名转小写
			ext = ext.toLowerCase();

			console.log(isInArray(imageExt, ext));

			// 判断扩展
			if (!isInArray(imageExt, ext)) {
				$(this).next().text("允许的图片格式是：" + imageExt.join(","));
			} else {
				$(this).next().text("");

				// 使用原生的获取元素
				var _this = document.getElementById("images");

				// 预览图片
				showImage(_this, "showimage");

			}

		})
		
		
		$("#tid").change(function(){
			var tname = $("#tid :checked").data("name");
			$("#tname").val(tname);
			
		})
	})
	
</script>



<div class="row">
	<ol class="breadcrumb">
		<li><a href="${baseurl }/admin">首页</a></li>
		<li class=""><a href="${baseurl }/admin/blog/list/1">博客管理</a></li>
		<li class="active">博客新增新增</li>
	</ol>
</div>

<div class="row" id="id_form">
	<form action="${baseurl }/admin/blog/add"  class="" method="post" enctype="multipart/form-data">
		<div class="form-group">
			<label for="title">标题</label> <input
				type="text" class="form-control" id="title" name="title"
				placeholder="标题" >
				<p class="text-danger"></p>
		</div>
		
		<div class="form-group">
			<label for="tid">分类</label>
			<select id="tid" name="tid" class="form-control ">
			  <c:forEach var="i" items="${onetype }">
			  	<option data-name="${i.name }"  value="${i.id }">${i.name }</option>
			  </c:forEach>
			</select>
		</div>
		
		<input id="tname" type="hidden" name="tname" value="${onetype != null ? onetype[0].name : '' }">
		
		
		<div class="form-group">
			<label for="images">封面</label> <input maxlength="6" type="file" name="images" accept="image/*"
				id="images" multiple="multiple">
			<p class="text-danger"></p>
			<!-- 图片与预览的div -->
			<div id="showimage"></div>
		</div>
		
		<div class="form-group">
			<label for="label">标签</label> <input
				type="text" class="form-control" id="label" name="label"
				placeholder="标签" >
				<p class="text-danger"></p>
		</div>
		
		<div class="form-group">
			<label for="tid">是否显示</label>
			<select id="isshow" name="isshow" class="form-control ">
			  	<option  value="Y">Y</option>
			  	<option  value="N">N</option>
			</select>
		</div>
		
		<div class="form-group">
			<label for="tid">是否删除</label>
			<select id="isdel" name="isdel" class="form-control ">
			  	<option  value="Y">Y</option>
			  	<option  value="N" selected="selected">N</option>
			</select>
		</div>
		
		<div class="form-group">
			<label for="readingnum">阅读量</label> <input
				type="number" class="form-control" id="readingnum" name="readingnum"
				placeholder="" >
				<p class="text-danger"></p>
		</div>
		
		<div class="form-group">
			<label for="style">样式</label> 
			<select id="style" name="style" class="form-control ">
			  	<option  value="1">样式1</option>
			  	<option  value="2">样式2</option>
			  	<option  value="3">样式3</option>
			</select>
		</div>
		
		<div class="form-group">
			<label for="describe">描述</label>
			<textarea id="describe" name="describe" class="form-control" rows="3"></textarea>
				<p class="text-danger"></p>
		</div>
		
		<div id="ueditor_container" class="form-group">
			<label for="content">内容</label>
			<!-- <textarea id="content" name="content" class="form-control" rows="3"></textarea>
				<p class="text-danger"></p> -->
				
				<!-- 加载编辑器的容器 -->
			<script id="container" name="content" type="text/plain"></script>
		</div>
		
		
		<button type="submit" class="btn btn-success" id="adduser">提交</button>
		<button type="reset" class="btn btn-primary" >重置</button>
		<button type="button" class="btn btn-warning returnPage">返回</button>
	</form>
</div>


<%@ include file="footer.jsp"%>

